package io.renren.modules.subject.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.renren.modules.meta.entity.EventEntity;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
public class BaseSubject implements Serializable {
    /**
     * 主键ID
     */
    @TableId
    private Long id;
    /**
     * 主体名字
     */
    private String name;

    @TableField(exist = false)
    private List<EventEntity> events;

    public void addEvent(EventEntity event) {
        if (events == null) {
            events = new ArrayList<>();
        }
        events.add(event);
    }

    public void removeEvent(EventEntity event) {
        if (events != null) {
            events.remove(event);
        }
    }
}
